剑指 Offer 63. 股票的最大利润
假设把某股票的价格按照时间先后顺序存储在数组中，请问买卖该股票一次可能获得的最大利润是多少？

https://leetcode.cn/problems/gu-piao-de-zui-da-li-run-lcof/description/?favorite=xb9nqhhg



双指针
int maxProfit(int* prices, int pricesSize)
{
    if(pricesSize==0)
    {
        return 0;
    }
    int len=pricesSize-1;
    int head=0;
    int taill=len;
    int max=prices[taill]-prices[head];
    while(head<taill)
    {
        while(head<taill)
        {
            if((max<prices[taill]-prices[head])&&(prices[taill]>prices[head]))
            {
                max=prices[taill]-prices[head];
            }
            taill--;
        }
        head++;
        taill=len;
    }
    if(max<0)
    {
        return 0;
    }
    else
    {
        return max;
    }

}